/**
 * Created by Administrator on 2017/5/22.
 */
angular.module('module.verification', [
    'ngCookies'
])
    .config(['$stateProvider',   '$urlRouterProvider',
        function($stateProvider, $urlRouterProvider) {
            $stateProvider
                .state('verification', {
                    url : '/verification',
                    templateUrl : 'view/verification/verification.html',
                    controller : 'VerificationController'
                })
                .state('verificationlist', {
                    url : '/verificationlist/?verificationid&code',
                    templateUrl : 'view/verification/verificationlist.html',
                    controller : 'VerificationlistController'
                })
        }])
    .controller('VerificationController', ['$scope','$state','$cookieStore','AuthService',
        function($scope,$state,$cookieStore,AuthService) {
            //var shopid = $cookieStore.get("_shopid");
            var shopid =$cookieStore.get('shopid');
            $scope.code = "";
            $scope.versummit = function(code){
                var data = {
                    shopid:shopid,
                    code:code,
                };
                console.log(data);
                AuthService.getvericode(data).$promise.then(function(list){
                    $state.go('verificationlist',{verificationid:list.verificationid,code:code})
                },function(error){
                    alert(error.data.message)
                })
            }
        }])
    .controller('VerificationlistController', ['$scope','$stateParams','$state','$cookieStore','OrderService',
        function($scope,$stateParams,$state,$cookieStore,OrderService) {
            var verificationid = $stateParams.verificationid;
            var code = $stateParams.code;
            OrderService.getByid(verificationid).$promise.then(function(order){
                console.log(order);
                $scope.order =order;
                $scope.code =code;
            },function(error){
                console.log(error);
            })

            $scope.backup=function(){
                $state.go('verification')
            }

        }])